home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / GetOffsetGlyphs Example.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  3.1 KB  |  110 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17. #include "layout feature constants.h"
  18.  
  19. #include "SampleInterface.h"
  20.  
  21. short MyStrLen(char *x);
  22. static short MyStrLen(x)
  23. char    *x;
  24.     {
  25.     short c = 0;
  26.     while (*x++) c++;
  27.     return c;
  28.     }    /* MyStrLen */
  29.  
  30. void GetOffsetGlyphsExample(WindowPtr sampleWindow)
  31.     {
  32.     /* Variables */
  33.     char                *myString = "ctspfifl";
  34.     gxLayoutOffsetState    offsetState;
  35.     gxPoint                myPoint;
  36.     gxRectangle            boundingBoxes[20];
  37.     gxRunFeature            gxRunFeature[5];
  38.     gxShape                layout;
  39.     short                len, level = 0;
  40.     gxStyle                myStyle;
  41.     unsigned short        firstGlyph, secondGlyph;
  42.     gxViewPort            aViewPort;
  43.     
  44.     /* Initialization */
  45.     
  46.     myPoint.x = ff(20);
  47.     myPoint.y = ff(80);
  48.     
  49.     aViewPort = GXNewWindowViewPort(sampleWindow);
  50.     SetDefaultViewPort(aViewPort);
  51.     
  52.     len = MyStrLen(myString);
  53.     
  54.     myStyle = NewLayoutStyle((char *) "\pHoefler Text Italic", ff(60), 0, nil, nil, 0, nil);
  55.     gxRunFeature[0].featureType = ligatureType;
  56.     gxRunFeature[0].featureSelector = ligatureRequiredOffSelector;
  57.     gxRunFeature[1].featureType = ligatureType;
  58.     gxRunFeature[1].featureSelector = ligatureCommonOffSelector;
  59.     gxRunFeature[2].featureType = ligatureType;
  60.     gxRunFeature[2].featureSelector = ligatureRareOffSelector;
  61.     gxRunFeature[3].featureType = ligatureType;
  62.     gxRunFeature[3].featureSelector = ligatureLogotypeOffSelector;
  63.     gxRunFeature[4].featureType = ligatureType;
  64.     gxRunFeature[4].featureSelector = ligatureRebusOffSelector;
  65.     GXSetStyleRunFeatures(myStyle, 5, gxRunFeature);
  66.     
  67.     layout = GXNewLayout(
  68.         1, &len, (void *) &myString,
  69.         1, &len, &myStyle,
  70.         1, &len, &level,
  71.         nil, &myPoint);
  72.     GXDrawShape(layout);
  73.     GXGetOffsetGlyphs(layout, 6, false, &offsetState, &firstGlyph, &secondGlyph);
  74.     GXGetGlyphMetrics(layout, nil, boundingBoxes, nil);
  75.     GXDrawRectangle(boundingBoxes + firstGlyph - 1, gxClosedFrameFill);
  76.     GXDisposeShape(layout);
  77.     
  78.     gxRunFeature[1].featureSelector = ligatureCommonOnSelector;
  79.     GXSetStyleRunFeatures(myStyle, 5, gxRunFeature);
  80.     myPoint.y += ff(75);
  81.     
  82.     layout = GXNewLayout(
  83.         1, &len, (void *) &myString,
  84.         1, &len, &myStyle,
  85.         1, &len, &level,
  86.         nil, &myPoint);
  87.     GXGetOffsetGlyphs(layout, 6, false, &offsetState, &firstGlyph, &secondGlyph);
  88.     GXDrawShape(layout);
  89.     GXGetGlyphMetrics(layout, nil, boundingBoxes, nil);
  90.     GXDrawRectangle(boundingBoxes + firstGlyph - 1, gxClosedFrameFill);
  91.     GXDisposeShape(layout);
  92.  
  93.     gxRunFeature[2].featureSelector = ligatureRareOnSelector;
  94.     GXSetStyleRunFeatures(myStyle, 5, gxRunFeature);
  95.     myPoint.y += ff(75);
  96.     
  97.     layout = GXNewLayout(
  98.         1, &len, (void *) &myString,
  99.         1, &len, &myStyle,
  100.         1, &len, &level,
  101.         nil, &myPoint);
  102.     GXGetOffsetGlyphs(layout, 6, false, &offsetState, &firstGlyph, &secondGlyph);
  103.     GXDrawShape(layout);
  104.     GXGetGlyphMetrics(layout, nil, boundingBoxes, nil);
  105.     GXDrawRectangle(boundingBoxes + firstGlyph - 1, gxClosedFrameFill);
  106.     GXDisposeShape(layout);
  107.     GXDisposeStyle(myStyle);
  108.     GXDisposeViewPort(aViewPort);
  109.     }    /* main */
  110.